<template>
	<view class="page">
		<!-- 订单tab -->
		<view class="order-tab">
			<view class="tab" :class="{'action':OrderType==0}" @click="onOrderTab(0)">
				<text>售后申请</text>
				<text class="line"></text>
			</view>
			<view class="tab" :class="{'action':OrderType==1}" @click="onOrderTab(1)">
				<text>处理中</text>
				<text class="line"></text>
			</view>
			<view class="tab" :class="{'action':OrderType==2}" @click="onOrderTab(2)">
				<text>售后评价</text>
				<text class="line"></text>
			</view>
			<view class="tab" :class="{'action':OrderType==3}" @click="onOrderTab(3)">
				<text>申请记录</text>
				<text class="line"></text>
			</view>
		</view>
		<!-- 订单搜索 -->
		<view class="order-search">
			<view class="search">
				<text class="iconfont icon-fadajing"></text>
				<input type="text" placeholder="商品名称/商品编号/订单号/序列号">
			</view>
			<view class="filtrate" @click="isFiltrate = true">
				<text>筛选</text>
			</view>
		</view>
		<!-- 订单列表 -->
		<view class="order-list" v-for="(item,index) in orderList" :key="index">
			<view class="list">
				<view class="order-number">
					<view class="number">
						<text>服务单号：{{item.order_no}}</text>
					</view>
					<view class="type">
						<image src="/static/sale_th.png" mode=""></image>
						<text>退货</text>
					</view>
				</view>
				<view class="goods-list" v-for="(value,key) in item.orderGoodsInfo">
					<view class="list">
						<view class="thumb">
							<image :src="value.goods_img" mode=""></image>
						</view>
						<view class="item">
							<view class="title">
								<text class="two-omit">{{value.goods_info}}</text>
							</view>
							<view class="num">
								<text>申请数量：1</text>
							</view>
						</view>
					</view>
				</view>
				<view class="order-status" v-if="OrderType != 0">
					<text>审核中</text>
					<text>当前订单退货审核中</text>
				</view>
				<view class="order-btn" v-if="OrderType === 0">
					<text class="action" @click="OnafterSale(item.id)">申请售后</text>
				</view>
			</view>
		</view>
		<!-- 筛选弹窗 -->
		<view class="filtrate-win" @click="isFiltrate = false">
			<view class="cu-modal drawer-modal justify-end" :class="{'show':isFiltrate}">
			  <view class="cu-dialog basis-lg">
			    <view class="order-time">
						<view class="title">
							<text>下单时间</text>
						</view>
						<view class="time-list">
							<view class="list action">
								<text>全部</text>
							</view>
							<view class="list">
								<text>一个月内</text>
							</view>
							<view class="list">
								<text>一个月至三个月</text>
							</view>
							<view class="list">
								<text>三个月六个月</text>
							</view>
							<view class="list">
								<text>六个月至一年</text>
							</view>
							<view class="list">
								<text>一年以上</text>
							</view>
						</view>
					</view>
					<view class="footer-btn">
						<view class="btn" @click="isFiltrate = false">
							<text>重置</text>
						</view>
						<view class="btn action" @click="isFiltrate = false">
							<text>确定</text>
						</view>
					</view>
			  </view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				OrderType: 0,
				isFiltrate: false,
				orderList:[]
			};
		},
		methods:{
			/**
			 * 订单tab切换状态
			 * @param {Number} type
			 */
			onOrderTab(type){
				console.log(type)
				this.OrderType = type;
				uni.showLoading({title: '加载中',mask:true});
				this.$http.get('order/AfterSale', {
					status:this.OrderType
				},{}).then(res => {
					if(res.data.data.length >0){
						console.log(res.data.data)
						this.orderList = res.data.data
						setTimeout(function () {uni.hideLoading();}, 100);
					}else{
						this.orderList = []
						setTimeout(function () {uni.hideLoading();}, 100);
						uni.showToast({
						    title: "没有您要找的数据",
						    duration: 2000,
							icon:"none"
						});
					}
				})
			},
			OnafterSale(orderId){
				console.log(orderId)
				uni.navigateTo({
					url:"/pages/AfterSaleType/AfterSaleType?orderId=" + orderId
				})
			}
		},
		onLoad() {
			uni.showLoading({title: '加载中',mask:true});
			this.$http.get('order/AfterSale', {
				status:this.OrderType
			},{}).then(res => {
				console.log(res.data.data)
				if(res.data.data.length >0){
					this.orderList = res.data.data
					setTimeout(function () {uni.hideLoading();}, 100);
				}else{
					this.orderList = []
					setTimeout(function () {uni.hideLoading();}, 100);
					uni.showToast({
					    title: "没有您要找的数据",
					    duration: 2000,
						icon:"none"
					});
				}
				
			})
		}
	}
</script>

<style scoped lang="scss">
	@import 'AfterSalesOrder.scss';
</style>
